package com.kujie.websocket.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;

/**
 * The format of WebSocket messages that the pilot can receive.
 * @author wang yihui
 * @date 2021/11/17
 * @desc WebSocketMessageResponse websocket 消息的统一返回结果类
 * @version 0.1
 */
@Getter
public class WebSocketMessageResponse<T> {

    @JsonProperty("biz_code")
    @NotNull
    private String bizCode;

    private String version = "1.0";

    @NotNull
    @Min(123456789012L)
    private Long timestamp;

    @NotNull
    private T data;

    public WebSocketMessageResponse() {
    }

    @Override
    public String toString() {
        return "WebSocketMessageResponse{" +
                "bizCode=" + bizCode +
                ", version='" + version + '\'' +
                ", timestamp=" + timestamp +
                ", data=" + data +
                '}';
    }

    public WebSocketMessageResponse<T> setBizCode(String bizCode) {
        this.bizCode = bizCode;
        return this;
    }

    public WebSocketMessageResponse<T> setVersion(String version) {
        this.version = version;
        return this;
    }

    public WebSocketMessageResponse<T> setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
        return this;
    }

    public WebSocketMessageResponse<T> setData(T data) {
        this.data = data;
        return this;
    }
}